package com.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dao.mapper.FamilyDao;
import com.domain.Family;
import com.domain.Jzlx;
import com.service.FamilyService;
import com.utils.ObjectUtils;
@Service(value="familyService")
public class FamilyServerImpl implements FamilyService{
	
	@Autowired
	FamilyDao familyDao;

	@Override
	public List<Map<String,Object>> getFamily(Map params) {
		List<Map<String,Object>> family = null;
		family = familyDao.getFamilys(params);
		return family;
	}

	@Override
	public int getCount(Map params) {
		int count = 0;
		count = familyDao.getCount(params);
		return count;
	}

	@Override
	public Map<String,Object> getPomrByUid(int fid) {
		Map<String,Object> family = new HashMap<String,Object>();
		family = familyDao.getFamilyByid(fid);
		return family;
	}

	@Override
	public Map<String, Object> getFamilyMapInfo(int fid) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int getHzid(String hzxm) {
		String uid = ObjectUtils.getStrVal(familyDao.getHzid(hzxm).get("uid"));
		return ObjectUtils.getIntVal(uid);
	}

	
	@Override
	public int getZflx(String zfmc) {
		Object obj = familyDao.getZflx(zfmc).get("jid");
		String jid = ObjectUtils.getStrVal(obj);
		return ObjectUtils.getIntVal(jid);
	}

	@Override
	public int getJdjg(String oname) {
		// TODO Auto-generated method stub
		String oid = ObjectUtils.getStrVal(familyDao.getJdjg(oname).get("oid"));
		return ObjectUtils.getIntVal(oid);
	}

	@Override
	public int getFzys(String ysmc) {
		String yid = ObjectUtils.getStrVal(familyDao.getFzys(ysmc).get("yid"));
		return ObjectUtils.getIntVal(yid);
	}

	@Override
	public void updateFamily(Family family) {
		
		familyDao.updateFamily(family);
	}

	@Override
	public List<Jzlx> getListZjlx() {
		// TODO Auto-generated method stub
		return familyDao.getListJzlx();
	}

	@Override
	public void addFamily(Family family) {
		familyDao.addFamily(family);
		
	}

	@Override
	public void deleteFamily(int fid) {
		familyDao.deleteFamily(fid);
		
	}

	@Override
	public Map<String, Object> getFamilyInfoByUcode(int ucode) {
		
		Map<String,Object> mapFamily = new HashMap<String,Object>(); 
				
		mapFamily = familyDao.getFamilyInfoByUcode(ucode);
		
		if(null == mapFamily){
			mapFamily.put("msg","该用户不存在家庭档案信息！");
		}
		return mapFamily;
	}

	
}
